﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZSoftPintrest.Domain;

namespace ZSoftPintrest.DataAccess.Config
{
    public class ChannelConfig: EntityTypeConfiguration<Channel>
    {
        public ChannelConfig()
        {
            this.HasKey(c => c.Id);

            this.HasMany(c => c.Comments)
                .WithRequired(c => c.Channel)
                .HasForeignKey(c => c.ChannelId);

            this.HasMany(c => c.Tags)
                .WithMany(t => t.Channels)
                .Map(t => t.MapLeftKey("ChannelId").MapRightKey("TagId").ToTable("ChannelTag"));
        }
    }
}
